<?php include_once 'Pecahan/sessionLontong.php'; ?>
<?php
if (isset($_GET['name_viewed'])!= NULL) {
    $name_viewed = $_GET['name_viewed'];
}
else if (isset($_SESSION['user_name'])!= NULL) {
    $name_viewed = $_SESSION['user_name'];
}
if (isset($_SESSION['user_name'])!= NULL) {
    $name_logon = $_SESSION['user_name'];
    $temp = new login();
    $role = $temp->getRole($name_logon );
}
else {
    $name_logon = NULL;
    $role = NULL;
}
?>
<?php
include_once'controller/registrasi.php';
include_once'controller/login.php';
include_once 'controller/follow.php';
include_once 'controller/photo.php';

$getID = new photo();
$photo_id = $getID->showPhotoID($name_viewed, $_GET['url_foto']);
if(isset ($_POST['sendComPhotoButton'])) {
    $getID->addPhotoCom($name_viewed, $_GET['url_foto'], $name_logon, $_POST['bodymessage']);
}
if(isset ($_GET['likes'])) {
    if(!$getID->isHasScored($photo_id, $name_logon)) {
        if(($_GET['likes']) == 'yes') {
            $int = 1;
            $getID->addPhotoVal($name_logon, $_GET['url_foto'], $name_viewed, $int);
            echo'like';
        }
        else if (($_GET['likes']) == 'no') {
            $int = -1;
            $getID->addPhotoVal($name_logon, $_GET['url_foto'], $name_viewed, $int);
            echo'dislike';
        }
    }
}
if (isset ($_POST['submit_button_save'])) {
    $updateFoto = new photo();
    $updateFoto->editPhoto('1', $_SESSION['user_name'], $_GET['url_foto'], $_POST['dekripsi']);
    $updateFoto->editPhoto('2', $_SESSION['user_name'], $_GET['url_foto'], $_POST['kata_kunci']);
    $updateFoto->editPhoto('3', $_SESSION['user_name'], $_GET['url_foto'], $_POST['tanggal']);
    $updateFoto->editPhoto('5', $_SESSION['user_name'], $_GET['url_foto'], $_POST['kategori']);
    $updateFoto->editPhoto('6', $_SESSION['user_name'], $_GET['url_foto'], $_POST['penglihat']);
    $updateFoto->editPhoto('7', $_SESSION['user_name'], $_GET['url_foto'], $_POST['penglihatKom']);
}
?>
<?php $judul = 'Foto Tagging'; ?>
<?php include_once 'Pecahan/header.php'; ?>

<div id ="content" class="isipage">
    <div class="isipagestandar">
        <div>
            <label id="titlebold"><?php echo 'Albumnya '.$name_viewed;  ?></label>
        </div>
    </div>
    <div class="space">

    </div>
    <div class="isisebelahfoto">
        <div>
            <label class="labelinput" id="titlebold">Description: </label>
            <label class="input" id="desc"><?php echo $getID->getPhotoDesc($photo_id); ?></label>
        </div>
        <div class="space"></div>
        <div>
            <label class="labelinput" id="titlebold">Keyword: </label>
            <label class="input" id="keyword"><?php echo $getID->getKeyWord($photo_id); ?></label>
        </div>
        <div class="space"></div>
        <div>
            <label class="labelinput" id="titlebold">Category: </label>
            <label class="input" id="category"><?php echo  $getID->getCategory($photo_id); ?></label>
        </div>
        <div class="space"></div>
        <div>
            <label class="labelinput" id="titlebold">Captured: </label>
            <label class="input"><?php echo $getID->getCaptDate($photo_id); ?></label>
        </div>
        <div class="space"></div>
        <div>
            <label class="labelinput" id="titlebold">Uploaded: </label>
            <label class="input"><?php echo  $getID->getPostDate($photo_id); ?></label>
        </div>
        <div class="space"></div>
    </div>
    <div class="space">

    </div>
    <div class="isipagestandar">
        <div class="photozoomtag">
            <?php
            echo'<img src="'.$_GET['url_foto'].'" alt="photozoom" height="400" width="560" border="0"/>';
            ?>
        </div>
    </div>
    <div class="space">

    </div>
    <div class="isipagestandar">
        <div class="tagfollowed">
            <label id="titlebold">Tag Followed User</label>
            <div class="space">
            </div>
            <form name="usertagged" action="<?php echo 'foto_zoom.php?name_viewed='.$name_viewed .'&url_foto=' . $_GET['url_foto'];?>" method="post">
                <?php
                $fo = new follow();
                $resultFo = $fo->showFollowing($name_viewed);
                while ($rowFo = mysql_fetch_array($resultFo)) {
                    ?>
                <div>
                    <input type="checkbox" name="usertotag[]" value="<?php echo $rowFo['user_name_following'];?>"> <?php echo $rowFo['user_name_following'];?>
                </div>
                <div class="space"></div>
                    <?php } ?>
                <div>
                    <input type="submit" name="donetagging" value="Done Tagging">
                </div>
            </form>
        </div>
        <div class ="arrowphoto">

        </div>
        <div class ="arrowphoto">

        </div>
    </div>
    <div class="space">

    </div>

</div>
<?php include_once 'Chat/chat.php';?>
<?php include_once 'Pecahan/footer.php'; ?>